package start.service;

import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import start.entity.UserDto;

@Slf4j
@Service
public class UserService {


    //@Cacheable
    @Cacheable(value = "getUserById", key = "#id")
    public UserDto getUserById(Long id){
        log.info("CacheConfig获取用户方法执行ID:" + id);
        UserDto user = new UserDto();
        user.setId(1L);
        user.setName("TT");
        return user;
    }

    //@Cacheable
    @Cacheable(value = "getUserByIdExpire", key = "#id")
    public UserDto getUserByIdExpire(Long id){
        log.info("CacheConfig获取用户方法执行ID:" + id);
        UserDto user = new UserDto();
        user.setId(1L);
        user.setName("TT-EXPIRE");
        return user;
    }






}
